package com.iotechn.unimall.data.dto.goods;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.iotechn.unimall.data.domain.*;
import com.iotechn.unimall.data.dto.CategoryDTO;
import com.iotechn.unimall.data.dto.SuperDTO;
import com.iotechn.unimall.data.dto.appraise.AppraiseResponseDTO;
import com.iotechn.unimall.data.dto.freight.FreightTemplateDTO;
import com.iotechn.unimall.data.model.Page;
import lombok.Data;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

/**
 * Created by rize on 2019/7/2.
 */
@Data
public class LogDTO extends SuperDTO {

    private List<SkuDO> skuList;

    private List<ShopBiaozhunLogDO> biaozhunList;

    private List<ShopBiaozhunDO> biaozhunInfoList;

    private Integer originalPrice;

    private Integer price;

    private Integer vipPrice;

    private Integer stock;

    private Integer sales;

    private String title;
    private String titleUrl;
    private Integer type;

    /**
     * 主图
     */
    private String img;

    /**
     * 后面的图，仅在详情接口才出现
     */
    private List<String> imgList;

    private String detail;

    private String description;

    private Long categoryId;

    private List<Long> categoryIds;

    private List<CategoryDTO> categoryList;

    private List<SpuAttributeDO> attributeList;

    /**
     * 商品的第一页(前10条)评价
     */
    private Page<AppraiseResponseDTO> appraisePage;

    /**
     * 商品现在携带的团购信息
     */
    private GroupShopDTO groupShop;

    private String unit;

    private Long freightTemplateId;

    private FreightTemplateDTO freightTemplate;

    private Boolean collect;

    private Integer status;
    //商品是谁的
    private Long userId;
    private Long shopId;
    private UserShopDO userShopDO;

    private String realName;
    private String shopName;
    private String area;
    private String pianarea;
    private String biaoduan;
    private String tianqi;
    private Date gmt_day;

    private List<FileInfo> fileList;
    private String file;
  /*  public List<String> getImgList(){
        if(img!=null && !img.equals("")){
            String[] arr = img.split(",");
            List<String> list = Arrays.asList(arr);
            return list;
        }
        return imgList;

    }*/
    public List<FileInfo> getFile(){
        if(file!=null && !file.equals("")){
            Gson gson=new Gson();
            List<FileInfo> fileInfoList = gson.fromJson(file, new TypeToken<List<FileInfo>>(){}.getType());
            return fileInfoList;
        }
        return fileList;

    }
}